import Loading from '@/layouts/Loading';
import React, { Suspense, lazy } from 'react';

/**
 * @author liyuan
 * @date 06-06 10:28:02
 * @desc 异步组件懒加载，会导致页面渲染慢，不过对于出现重组件页面可以使用，减少首页加载时间
 */
const lazyComponent = (
  importComponent: () => Promise<{
    default: React.ComponentType<any>;
  }>,
) => {
  const Component = lazy(importComponent);
  return (
    <Suspense fallback={<Loading />}>
      <Component />
    </Suspense>
  );
};
export default lazyComponent;
